home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-28 | 2.1 KB | 85 lines | [TEXT/MPS ] |
- /*
- File: SplashWindow.cp
-
- Contains: a simple splash screen window
-
- Written by: Dave Falkenburg
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- <6> 11/16/94 DRF Add (StringPtr) cast to make PPCC happier.
- <5> 11/12/94 DRF Use NewColorOrBlackAndWhiteWindow.
- <4> 11/8/94 DRF Deal with a missing splash picture.
- <3> 9/27/94 DRF AppLib.h is now Sprocket.h
- <2> 9/9/94 DRF Reordered headers and removed redundant #includes.
- */
-
- #include "Sprocket.h"
- #include "SplashWindow.h"
-
- #include <ToolUtils.h>
- #include <Resources.h>
-
-
- TSplashWindow::TSplashWindow()
- {
- this->CreateWindow(kNormalWindow);
- }
-
-
- TSplashWindow::~TSplashWindow()
- {
- if (fSplashPicture)
- DisposeHandle((Handle) fSplashPicture);
-
- this->Close();
- }
-
-
- WindowPtr
- TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
- {
- GrafPtr oldPort;
- Rect splashPictRect,windowRect;
- WindowPtr splashWindow;
-
- GetPort(&oldPort);
-
- fSplashPicture = GetPicture(kSplashPictureID);
-
- if (fSplashPicture)
- {
- MoveHHi((Handle) fSplashPicture); // get it out of the way
- splashPictRect = (**fSplashPicture).picFrame;
- }
- else
- SetRect(&splashPictRect,0,0,0,0);
-
- // normalize the rectangle
- OffsetRect(&splashPictRect,-splashPictRect.left,-splashPictRect.top);
-
- // center it on the main screen
- windowRect = splashPictRect;
- OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
-
- splashWindow = NewColorOrBlackAndWhiteWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
-
- if (fSplashPicture)
- {
- DetachResource((Handle) fSplashPicture); // need to do so we don’t botch the resource map after closing
- SetWindowPic(splashWindow,fSplashPicture); // in case an Alert comes up
- }
-
- ShowWindow(splashWindow);
- SetPort(splashWindow);
- BeginUpdate(splashWindow); // avoid a flashing update event later
- if (fSplashPicture)
- DrawPicture(fSplashPicture,&splashPictRect);
- EndUpdate(splashWindow); // avoid a flashing update event later
-
- SetPort(oldPort);
- return splashWindow;
- }
-